<template>
    <div>
        <el-row :gutter="10" style="margin: 0 10px;">
            <el-col :lg="24"> 
                <page-main title="" style="margin: 0 0 20px 0; height: 100%;">
                       <div  style="margin: 0 0 10px 0;">
                          <el-button-group>                     
                          <el-button type="primary" @click="getQuery" >查询所有房屋</el-button>
                        </el-button-group>
                      </div>
                 <div id="content">
                <table id="myTable" lay-filter="myTable"></table>
                 </div>
                </page-main>          
            </el-col>
        </el-row>
    </div>
</template>

<script>
import msApi from "@/api/msApi";
  export default {
    name: "test",
    data() {
      return {    
      }
    },
   		created() {  
       },
    
      mounted() {
               layui.use(['table','soulTable','FileSaver'], function () {
              var table = layui.table,
              soulTable = layui.soulTable
              , FileSaver = layui.FileSaver

            var myTable =  table.render({
                elem: '#myTable'
                ,toolbar: '<div><a class="layui-btn layui-btn-sm" lay-event="export"><i class="layui-icon layui-icon-download-circle"></i>查询</a>'+
                '<a class="layui-btn layui-btn-sm" lay-event="export"><i class="layui-icon layui-icon-download-circle"></i>导出所有数据</a>'+
                '<a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="export2"><i class="layui-icon layui-icon-download-circle"></i>导出勾选数据</a></div>'
                ,defaultToolbar: ['filter']           
                ,cols: [
                [
                    {type: 'checkbox', rowspan: 2, fixed: 'left'}
                  ,{type: 'numbers', title: '序号', rowspan: 2, fixed: 'left'}
                  ,{align: 'center', width: '100', field: 'suite', title: '户号', rowspan: 2, sort: true} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: 'room', title: '房间', rowspan: 2, sort: true} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '房顶', colspan: 2} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '地板', colspan: 2} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '东墙', colspan: 2} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '南墙', colspan: 2} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '西墙', colspan: 2} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '北墙', colspan: 2} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '东北阴阳角', colspan: 1} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '西北阴阳角', colspan: 1} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '东南阴阳角', colspan: 1} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '西南阴阳角', colspan: 1} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '净高', colspan: 2} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '净开间', colspan: 2} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '净进深', colspan: 2} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '门洞1', colspan: 1} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '门洞2', colspan: 1} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '窗洞1', colspan: 1} //rowspan 合并行]
                  ,{align: 'center', width: '100', field: '', title: '窗洞2', colspan: 1} //rowspan 合并行]
                
                ],
                [
                   {align: 'center', width: '100', field: 'ceiling_p', title: '平整度'}
                  ,{align: 'center', width: '100', field: 'ceiling_s', title: '水平度'}
                  ,{align: 'center', width: '100', field: 'floor_p', title: '平整度'}
                  ,{align: 'center', width: '100', field: 'floor_s', title: '水平度'}

                  ,{align: 'center', width: '100', field: 'ewalls_p', title: '平整度'}
                  ,{align: 'center', width: '100', field: 'ewalls_c', title: '垂直度'}
                  ,{align: 'center', width: '100', field: 'swalls_p', title: '平整度'}
                  ,{align: 'center', width: '100', field: 'swalls_c', title: '垂直度'}  
                  ,{align: 'center', width: '100', field: 'wwalls_p', title: '平整度'}
                  ,{align: 'center', width: '100', field: 'wwalls_c', title: '垂直度'}  
                  ,{align: 'center', width: '100', field: 'nwalls_p', title: '平整度'}
                  ,{align: 'center', width: '100', field: 'nwalls_c', title: '垂直度'}  

                  ,{align: 'center', width: '100', field: 'multiwalls_en', title: '方正度'}
                  ,{align: 'center', width: '100', field: 'multiwalls_wn', title: '方正度'}
                  ,{align: 'center', width: '100', field: 'multiwalls_es', title: '方正度'}
                  ,{align: 'center', width: '100', field: 'multiwalls_ws', title: '方正度'}

                  ,{align: 'center', width: '100', field: 'h_z', title: '偏差'}
                  ,{align: 'center', width: '100', field: 'h_j', title: '极差'}
                  ,{align: 'center', width: '100', field: 'bay_j', title: '偏差'}
                  ,{align: 'center', width: '100', field: 'bay_j', title: '极差'}
                  ,{align: 'center', width: '100', field: 'depth_z', title: '偏差'}
                  ,{align: 'center', width: '100', field: 'depth_j', title: '极差'}

                  ,{align: 'center', width: '100', field: 'door1', title: '偏差'}
                  ,{align: 'center', width: '100', field: 'door2', title: '偏差'}
                  ,{align: 'center', width: '100', field: 'window1', title: '偏差'}
                  ,{align: 'center', width: '100', field: 'window2', title: '偏差'}//这里门12，窗12的偏差以（高偏差/宽偏差）的形式展示
               ]]  
                ,data: [{
                  project:'户号1',
                  room:'房间1',
                  ceiling_p:'1',
                  ceiling_s:'2',
                  floor_p:'2',
                  floor_s:'4',
                  h_z:'2',
                  h_j:'5',
                  bay_z:'12',bay_j:'2',
                  depth_z:'5',depth_j:'2',
                  ewalls_p:'4',swalls_p:'3',wwalls_p:'1',nwalls_p:'1',
                  ewalls_c:'7',swalls_c:'11',wwalls_c:'0',nwalls_c:'0',
                  multiwalls_en:'0',multiwalls_wn:'0',multiwalls_es:'无',multiwalls_ws:'1', 
                  window1:'12',window2:'3',
                  door1:'14',door2:'11',
                }
                ]
                ,height: 500
                ,done: function () {
                  soulTable.render(this)
                }
                });

              table.on('toolbar(myTable)', function(obj){
                  if (obj.event === 'export') {
                      soulTable.export(myTable, {
                        filename: '导出所有数据.xlsx'
                      });
                  } else if (obj.event === 'export2') {
                    if (table.checkStatus('myTable').data.length > 0) {
                      soulTable.export(myTable, {
                        filename: '导出勾选数据.xlsx',
                        checked: true // 只导出勾选数据
                      });
                    } else {
                      layer.msg('勾选数据不能为空！');
                    }
                }
              });
            })
      },

    methods:{
     async getQuery(){//获取当前状态
            try {
              let res =await msApi.queryAllFinishedTasks()
              let param = new Array()
              let   ceiling_p=[],ceiling_s=[],
                    floor_p=[],floor_s=[],
                    h_z=[],h_j=[],
                    bay_z=[],bay_j=[],depth_z=[],depth_j=[],
                    ewalls_p=[],swalls_p=[],wwalls_p=[],nwalls_p=[],
                    ewalls_c=[],swalls_c=[],wwalls_c=[],nwalls_c=[],
                    multiwalls_en=[],multiwalls_wn=[],multiwalls_es=[],multiwalls_ws=[],
                    window1=[],window2=[],door1=[],door2=[]

              res.data.forEach(async(room,index) => {
                  param[index] = new Array(30)//创建二维数组
                  param[index]['taskId'] = room.task_id
                  param[index]['room'] = room.room_name
                  param[index]['suite'] = room.suite_name

              await msApi.getResult(param[index]['taskId']).then(res=>{
              let _walls = res.data.data.walls;
              let wall_info = res.data.data.wall_info;

              let wall_map = new Map();
              for(let i in wall_info){
              switch(wall_info[i]){
                case 'E':
                  wall_map.set("E",i);
                  if(_walls[i]==undefined){
                    continue;
                  }
                  const eastWall = _walls[i].measurements;
                  for(const key in eastWall){
                    switch(eastWall[key].id){
                      case "2":
                        param[index]['ewalls_p'] = (eastWall[key].value).toString();
                        const p_max = Math.max(...eastWall[key].value)
                        const p_min = Math.min(...eastWall[key].value)
                        if(p_max>=-4&&p_max<=4 && p_min>=-4&&p_min<=4){
                           ewalls_p[index] = '合格'
                        }else{
                           ewalls_p[index] = '不合格'
                        }
                        break;
                      case "3":
                        param[index]['ewalls_c'] = (eastWall[key].value).toString();
                        const c_max = Math.max(...eastWall[key].value);
                        const c_min = Math.min(...eastWall[key].value);
                        if(c_max>=-4&&c_max<=4 && c_min>=-4&&c_min<=4){
                          ewalls_c[index] = '合格'
                        }else{
                          ewalls_c[index] = '不合格'
                        }
                        break;
                    }
                  }
                break;
                case 'S':
                  wall_map.set("S",i)
                  if(_walls[i]==undefined){
                    continue;
                  }
                  const southWall = _walls[i].measurements;
                  for(const key in southWall){
                    switch(southWall[key].id){
                      case "2":
                        param[index]['swalls_p'] = (southWall[key].value).toString();
                        const p_max = Math.max(...southWall[key].value);
                        const p_min = Math.min(...southWall[key].value);
                        if(p_max>=-4&&p_max<=4 && p_min>=-4&&p_min<=4){
                          // this.swalls_pr = '合格'
                        }else{
                          // this.swalls_pr = '不合格'
                        }
                        break;
                      case "3":
                        param[index]['swalls_c'] = (southWall[key].value).toString();
                        const c_max = Math.max(...southWall[key].value);
                        const c_min = Math.min(...southWall[key].value);
                        if(c_max>=-4&&c_max<=4 && c_min>=-4&&c_min<=4){
                          // this.swalls_cr = '合格'
                        }else{
                          // this.swalls_cr = '不合格'
                        }
                        break;
                    }
                  }
                  break;
                case 'W':
                  wall_map.set("W",i);
                  if(_walls[i]==undefined){
                    continue;
                  }
                  const westWall = _walls[i].measurements;
                  for(const key in westWall){
                    switch(westWall[key].id){
                      case "2":
                        param[index]['wwalls_p'] = (westWall[key].value).toString();
                        const p_max = Math.max(...westWall[key].value);
                        const p_min = Math.min(...westWall[key].value);
                        if(p_max>=-4&&p_max<=4 && p_min>=-4&&p_min<=4){
                          // this.wwalls_pr = '合格'
                        }else{
                          // this.wwalls_pr = '不合格'
                        }
                        break;
                      case "3":
                        param[index]['wwalls_c'] = (westWall[key].value).toString();
                        const c_max = Math.max(...westWall[key].value);
                        const c_min = Math.min(...westWall[key].value);
                        if(c_max>=-4&&c_max<=4 && c_min>=-4&&c_min<=4){
                          // this.wwalls_cr = '合格'
                        }else{
                          // this.wwalls_cr = '不合格'
                        }
                        break;
                    }
                  }
                  break;
                  case 'N':
                    wall_map.set("N",i);
                    if(_walls[i]==undefined){
                      continue;
                    }
                    const northWall = _walls[i].measurements;
                    for(const key in northWall){
                      switch(northWall[key].id){
                        case "2":
                          param[index]['nwalls_p'] = (northWall[key].value).toString();
                          const p_max = Math.max(...northWall[key].value);
                          const p_min = Math.min(...northWall[key].value);
                          if(p_max>=-4&&p_max<=4 && p_min>=-4&&p_min<=4){
                            // this.nwalls_pr = '合格'
                          }else{
                            // this.nwalls_pr = '不合格'
                          }
                          break;
                        case "3":
                          param[index]['nwalls_c'] = (northWall[key].value).toString();
                          const c_max = Math.max(...northWall[key].value);
                          const c_min = Math.min(...northWall[key].value);
                          if(c_max>=-4&&c_max<=4 && c_min>=-4&&c_min<=4){
                            // this.nwalls_cr = '合格'
                          }else{
                            // this.nwalls_cr = '不合格'
                          }
                          break;
                      }
                    }
                  break;
                }
              }
              //处理天花板水平极差数据
              // console.log(res.data.data.room.measurements)
              const ceiling_info = res.data.data.ceiling.measurements;
              for(let i in ceiling_info){
                if(ceiling_info[i].id=="4"){
                  //处理天花板水平度极差
                  let ceiling_arr = ceiling_info[i].value;  //这是一个array
                  // this.removeZero(ceiling_arr)                //数据降噪：去零处理
                  const _ceilingMax = Math.max(...ceiling_arr);
                  const _ceilingMin = Math.min(...ceiling_arr);
                  param[index]['ceiling_s'] = _ceilingMax - _ceilingMin;
                  //判断是否合格
                  // if(this.ceiling_s>=-4 && this.ceiling_s<=4){
                  //   this.ceiling_sr='合格'
                  // }else{
                  //   this.ceiling_sr='不合格'
                  // }
                }else if(ceiling_info[i].id=="2"){
                  //处理天花板平整度
                  // let ceiling_arr = ceiling_info[i].value;
                  param[index]['ceiling_p'] = (ceiling_info[i].value).toString();
                  const ceiling_p_max = Math.max(...ceiling_info[i].value);
                  // if(ceiling_s_max>=0 && ceiling_s_max<=4){
                  //   this.ceiling_pr = '合格'
                  // }else{
                  //   this.ceiling_pr = '不合格'
                  // }
                }
              }
              const floor_info = res.data.data.floor.measurements;
              for(let i in floor_info){
                if(floor_info[i].id=="4"){
                  //处理地板水平度极差
                  let floor_arr = floor_info[i].value;
                  // this.removeZero(floor_arr)
                 param[index]['floor_s'] = Math.max(...floor_arr) - Math.min(...floor_arr)
                  // if(this.floor_s>=0 && this.floor_s<=4){
                  //   this.floor_sr = '合格'
                  // }else{
                  //   this.floor_sr = '不合格'
                  // }
                }else if(floor_info[i].id=="2"){
                  //处理地板平整度数据
                  param[index]['floor_p'] = (floor_info[i].value);
                  const floor_p_max = Math.max(...floor_info[i].value).toString()
                  // if(floor_p_max>=-4 && floor_p_max<=4){
                  //   this.floor_pr = '合格'
                  // }else{
                  //   this.floor_pr = '不合格'
                  // }
                }
              }
              //处理阴阳角数据
              const multiwalls_info = res.data.data.multiwalls;
              const e_num = Number(wall_map.get('E'));
              const s_num = Number(wall_map.get('S'));
              const w_num = Number(wall_map.get('W'));
              const n_num = Number(wall_map.get('N'));
              for(let key in multiwalls_info){
                let walls_arr = multiwalls_info[key].walls;   //每个阴阳角两堵墙
                if( walls_arr.includes( e_num ) && walls_arr.includes( s_num ) ){
                  param[index]['multiwalls_es'] = (multiwalls_info[key].value).toString();
                  const es_max = Math.max(...multiwalls_info[key].value)
                  const es_min = Math.min(...multiwalls_info[key].value)
                  //最大最小都要在范围之内.相当于取了绝对值最大
                  // if(es_max>=-4&&es_max<=4 && es_min>=-4&&es_min<=4){
                  //   this.multiwalls_esr = '合格'
                  // }else{
                  //   this.multiwalls_esr = '不合格'
                  // }
                }else if( walls_arr.includes( e_num ) && walls_arr.includes( n_num )){
                  param[index]['multiwalls_en'] = (multiwalls_info[key].value).toString();
                  const en_max = Math.max(...multiwalls_info[key].value)
                  const en_min = Math.min(...multiwalls_info[key].value)
                  //最大最小都要在范围之内.相当于取了绝对值最大
                  // if(en_max>=-4&&en_max<=4 && en_min>=-4&&en_min<=4){
                  //   this.multiwalls_enr = '合格'
                  // }else{
                  //   this.multiwalls_enr = '不合格'
                  // }
                }else if( walls_arr.includes( w_num )&& walls_arr.includes( s_num )){
                  param[index]['multiwalls_ws'] = (multiwalls_info[key].value).toString();
                  const ws_max = Math.max(...multiwalls_info[key].value)
                  const ws_min = Math.min(...multiwalls_info[key].value)
                  //最大最小都要在范围之内.相当于取了绝对值最大
                  // if(ws_max>=-4&&ws_max<=4 && ws_min>=-4&&ws_min<=4){
                  //   this.multiwalls_wsr = '合格'
                  // }else{
                  //   this.multiwalls_wsr = '不合格'
                  // }
                }else if( walls_arr.includes( w_num )&& walls_arr.includes( n_num )){
                  param[index]['multiwalls_wn'] = (multiwalls_info[key].value).toString();
                  const wn_max = Math.max(...multiwalls_info[key].value)
                  const wn_min = Math.min(...multiwalls_info[key].value)
                  //最大最小都要在范围之内.相当于取了绝对值最大
                  // if(wn_max>=-4&&wn_max<=4 && wn_min>=-4&&wn_min<=4){
                  //   this.multiwalls_wnr = '合格'
                  // }else{
                  //   this.multiwalls_wnr = '不合格'
                  // }
                }
              }
              //处理房间开间、进深、高数据
              const room_info = res.data.data.room.measurements;
              let flag = 0;
              for(let i in room_info){
                //id=21,净开间最短、净开间最长、净进深最小值，净进深最大值顺序的四个数字
                if(room_info[i].id=="21"){
                  let bay_depth_arr = room_info[i].value;
                  //防止没测出数据，最大最小都为0的情况
                  if(bay_depth_arr[1]!=0 && bay_depth_arr[0]!=0){
                    //净开间极差
                    param[index]['bay_j'] = bay_depth_arr[1]-bay_depth_arr[0];
                    // param[index]['bay_z'] = bay_depth_arr[1]-this.bay_d;
                    // if(this.bay_j>=0 && this.bay_j<=20){
                    //   this.bay_jr = '合格';
                    // }else{
                    //   this.bay_jr = '不合格';
                    // }
                    // if(this.bay_z>=-15 && this.bay_z<=15){
                    //   this.bay_zr = '合格'
                    // }else{
                    //   this.bay_zr = '不合格'
                    // }
                  }
                  if(bay_depth_arr[3]!=0 && bay_depth_arr[2]!=0){
                    //净深极差
                    param[index]['depth_j'] = bay_depth_arr[3]-bay_depth_arr[2];
                    // param[index]['depth_z'] = bay_depth_arr[3]-this.depth_d;
                    // if(this.depth_j>=0 && this.depth_j<=20){
                    //   this.depth_jr = '合格';
                    // }else{
                    //   this.depth_jr = '不合格';
                    // }
                    // if(this.depth_z>=-15 && this.depth_z<=15){
                    //   this.depth_zr = '合格'
                    // }else{
                    //   this.depth_zr = '不合格'
                    // }
                    
                  }
                }
               
                //id=6,净高五尺实测值
                if(room_info[i].id=="6"){
                  const height_arr = room_info[i].value;
                  // this.h_d = height_arr[Math.floor((Math.random()*height_arr.length))]+12
                  // this.h_r = this.(height_arr);
                  //处理极差和最大偏差
                  param[index]['h_j'] = Math.max(...height_arr)-Math.min(...height_arr);
                  param[index]['h_z'] = Math.max(...height_arr)-this.h_d;
                  // const height_z_offset = Math.max(...height_arr)-this.h_d;
                  // this.heigth_z = height_z_offset;
                  // if(this.h_j>=0 && this.h_j<=20){
                  //   this.h_jr = '合格';
                  // }else{
                  //   this.h_jr = '不合格';
                  // }
                  // if(this.h_z>=-15 && this.h_z<=15){
                  //   this.h_zr = '合格'
                  // }else{
                  //   this.h_zr = '不合格'
                  // }
                }
              }
              //处理门、窗洞数据
              const openings_info = res.data.data.openings;
              // console.log(openings_info)
              let doorCount = 0; //记录门的个数
              let windowCount = 0;
              for(let i in openings_info){
                if(openings_info[i].measurements[0].id == '11'){
                  doorCount++;
                  //处理第一扇门
                  if(doorCount==1){
                    let door_arr = openings_info[i].measurements[0].value;
                    const door1_k_arr = door_arr.slice(0,2)
                    const door1_g_arr = door_arr.slice(2,4)
                    // this.door1_kd = door1_k_arr[Math.floor((Math.random()*door1_k_arr.length))]
                    // this.door1_gd = door1_g_arr[Math.floor((Math.random()*door1_g_arr.length))]
                    let door1_gr = (door1_g_arr)
                    let door1_kr = (door1_k_arr)
                    param[index]['door1'] = (door1_gr + door1_kr).toString()
                    //前两个是宽，后两个是高
                    // if(door_arr[0]!=0 && door_arr[1]!=0){
                    //   //宽的两个值都不能为0，如果有0，偏差和极差就没有意义了
                    //   this.door1_kz = Math.max(...door1_k_arr) - this.door1_kd;
                    //   this.door1_kj = Math.max(...door1_k_arr) - Math.min(...door1_k_arr)
                    // }
                    // //处理门1的高
                    // if(door_arr[2]!=0 && door_arr[3]!=0){
                    //   this.door1_gz = Math.max(...door1_g_arr) - this.door1_gd;
                    //   this.door1_gj = Math.max(...door1_g_arr) - Math.min(...door1_g_arr)
                    // }
                  }else if(doorCount==2){
                    //处理第二扇门
                    let door_arr = openings_info[i].measurements[0].value;
                    const door2_k_arr = door_arr.slice(0,2)
                    const door2_g_arr = door_arr.slice(2,4)
                    // this.door2_kd = door2_k_arr[Math.floor((Math.random()*door2_k_arr.length))]
                    // this.door2_gd = door2_g_arr[Math.floor((Math.random()*door2_g_arr.length))]
                    let door2_gr = (door2_g_arr)
                    let door2_kr = (door2_k_arr)
                    param[index]['door2'] = (door2_gr + door2_kr).toString()
                    //前两个是宽，后两个是高
                    // if(door_arr[0]!=0 && door_arr[1]!=0){
                    //   //处理门2的宽
                    //   this.door2_kz = Math.max(...door2_k_arr) - this.door2_kd;
                    //   this.door2_kj = Math.max(...door2_k_arr) - Math.min(...door2_k_arr)
                    // }
                    // if(door_arr[2]!=0 && door_arr[3]!=0){
                    //   //处理门2的高
                    //   this.door2_gz = Math.max(...door2_g_arr) - this.door2_gd;
                    //   this.door2_gj = Math.max(...door2_g_arr) - Math.min(...door2_g_arr)
                    // }
                  }else{
                    //不可能有两扇以上的门的
                    // console.log("门超过两扇了，不显示")
                    return
                  }
                }else if(openings_info[i].measurements[0].id == '5'){
                  //处理窗洞数据
                  windowCount++;
                  if(windowCount==1){
                    // console.log(openings_info[i].measurements[0].value)
                    let window_arr = openings_info[i].measurements[0].value;
                    const window1_k_arr = window_arr.slice(0,2)
                    const window1_g_arr = window_arr.slice(2,4)
                    // this.window1_kd = window1_k_arr[Math.floor((Math.random()*window1_k_arr.length))]
                    // this.window1_gd = window1_g_arr[Math.floor((Math.random()*window1_g_arr.length))]
                    let window1_gr = (window1_g_arr)
                    let window1_kr = (window1_k_arr)
                    param[index]['window1'] = (window1_gr + window1_kr).toString()
                    
                    //前两个是宽，后两个是高
                    // if(window_arr[0]!=0 && window_arr[1]!=0){
                    //   //宽的两个值都不能为0，如果有0，偏差和极差就没有意义了
                    //   this.window1_kz = Math.max(...window1_k_arr) - this.window1_kd;
                    //   this.window1_kj = Math.max(...window1_k_arr) - Math.min(...window1_k_arr)
                    // }
                    // //处理窗1的高
                    // if(window_arr[2]!=0 && window_arr[3]!=0){
                    //   this.window1_gz = Math.max(...window1_g_arr) - this.window1_gd;
                    //   this.window1_gj = Math.max(...window1_g_arr) - Math.min(...window1_g_arr)
                    // }
                  }else if(windowCount==2){
                    //处理窗2
                    // console.log(openings_info[i].measurements[0].value)
                    let window_arr = openings_info[i].measurements[0].value;
                    const window2_k_arr = window_arr.slice(0,2)
                    const window2_g_arr = window_arr.slice(2,4)
                    // this.window2_kd = window2_k_arr[Math.floor((Math.random()*window2_k_arr.length))]
                    // this.window2_gd = window2_g_arr[Math.floor((Math.random()*window2_g_arr.length))]
                    let window2_gr = (window2_g_arr)
                    let window2_kr = (window2_k_arr)
                    param[index]['window2'] = (window2_gr + window2_kr).toString()
                    //前两个是宽，后两个是高
                    // if(window_arr[0]!=0 && window_arr[1]!=0){
                    //   //处理窗2的宽
                    //   this.window2_kz = Math.max(...window2_k_arr) - this.window2_kd;
                    //   this.window2_kj = Math.max(...window2_k_arr) - Math.min(...window2_k_arr)
                    // }
                    // if(window_arr[2]!=0 && window_arr[3]!=0){
                    //   //处理窗2的高
                    //   this.window2_gz = Math.max(...window2_g_arr) - this.window2_gd;
                    //   this.window2_gj = Math.max(...window2_g_arr) - Math.min(...door2_g_arr)
                    // }
                  }else{
                    //不可能有两扇以上的门的
                    // console.log("窗超过两扇了，不显示")
                    return
                    }
                  }
                }
              })
              });
              setTimeout(function(){
                let l=param.length;
                let itemArray = new Array();
                for(let i=0;i<l;i++){
                  window["itemsObj"+i]=new Object();
                  for(let key in param[i]){==
                    window["itemsObj"+i][key]=param[i][key];
                  }
                  itemArray[i]=window["itemsObj"+i];
                }
                layui.use('table', function(){
                let table = layui.table;
                  table.reload('myTable', {
                  data:itemArray
                  })
              }) 
            },500)

            }catch (err) {
              console.log(err);
              this.$message.error('网络异常')
             }
      },
    }
  }
</script>
